<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class preport_model extends CI_Model {

	public function new_report($input)
	{
		$this->db->insert('report_vdo',$input);
	}

	public function get_report($vdo_id)
	{
		$this->db->where('report_vdo.vdo_id',$vdo_id);
		$this->db->where('vdo_thumb.thumb_choose',1);
		$this->db->join('vdo','vdo.vdo_id = report_vdo.vdo_id','left');
		$this->db->join('vdo_thumb','vdo_thumb.vdo_id = report_vdo.vdo_id','left');
		$this->db->join('member','member.mem_id = report_vdo.rvdo_from','left');
		$this->db->order_by('report_vdo.rvdo_id','asc');
		$query = $this->db->get('report_vdo');
		return $query->result_array();
	}

	public function get_group()
	{
		$this->db->select('vdo_name ,vdo_rawfile,thumb_name,report_vdo.vdo_id');
		$this->db->where('vdo_thumb.thumb_choose',1);
		$this->db->group_by('report_vdo.vdo_id');
		$this->db->join('vdo','vdo.vdo_id = report_vdo.vdo_id','left');
		$this->db->join('vdo_thumb','vdo_thumb.vdo_id = report_vdo.vdo_id','left');
		$this->db->join('member','member.mem_id = report_vdo.rvdo_from','left');
		$this->db->order_by('report_vdo.rvdo_id','asc');
		$query = $this->db->get('report_vdo');
		return $query->result_array();
	}

	public function del_report($rvdo_id)
	{
		$this->db->where('rvdo_id',$rvdo_id);
		$this->db->delete('report_vdo');
	}

	public function del_allvdo_report($rvdo_id)
	{
		$this->db->where('vdo_id',$rvdo_id);
		$this->db->delete('report_vdo');
	}
}